var CM_Function = new Object();
CM_Function.StringToBool = function(value) {
    return value === "true";
};
CM_Function.BoolToString = function(value) {
    if (value)
        return "true";
    return "false";
};
CM_Function.StringFormat = function(format) {

    var args = Array.prototype.slice.call(arguments, 1);
    var sprintfRegex = /\{(\d+)\}/g;

    var sprintf = function(match, number) {
        return number in args ? args[number] : match;
    };

    return format.replace(sprintfRegex, sprintf);
};

function Configuration(teamOneName, teamTwoName) {
    this.TeamOneName = teamOneName;
    this.TeamTwoName = teamTwoName;
    this.SiteArray = new Array();

    this.SetSiteInfo = function(siteInfoWK) {
        var index = this.GetSiteArrayIndex(siteInfoWK.Key);
        if (index === -1) {
            this.SiteArray.push(siteInfoWK);
            return;
        }
        this.SiteArray[index] = siteInfoWK;
    };

    this.GetSiteInfo = function(key) {
        var index = this.GetSiteArrayIndex(key);
        if (index === -1) {
            return null;
        }
        return this.SiteArray[index];
    };

    this.GetSiteArrayIndex = function(key) {
        for (var i = 0; i < this.SiteArray.length; i++)
        {
            if (this.SiteArray[0].Key === key)
                return i;
        }
        return -1;
    };
}

function SiteInfo(siteName, valueOne, valueTwo) {
    this.SiteName = siteName;
    this.ValueOne = valueOne;
    this.ValueTwo = valueTwo;
}

function SiteInfoWK(key, siteInfo) {
    this.Key = key;
    this.SiteInfo = siteInfo;
}
